package com.example.livemall.controller;

import com.example.livemall.dto.SearchResult;
import com.example.livemall.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品评论服务控制层
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 根据商品主键查询商品评论并处理分页
     *
     * @param itemId
     * @return
     */
    @GetMapping("")
    public SearchResult selectCommentByItemId(@RequestParam(value = "id") String itemId,
                                              int page, @RequestParam(defaultValue = "5") int size) {
        return commentService.selectCommentByItemId(itemId, page, size);
    }

}